package org.example.springboot3.controller;

import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.example.springboot3.common.Result;
import org.example.springboot3.entity.Album;
import org.example.springboot3.entity.Employee;
import org.example.springboot3.service.AlbumService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/album")
public class AlbumController {

    @Resource
     private AlbumService albumService;

    @GetMapping("/selectPage")
    public Result selectPage(Album album,
                             @RequestParam ( defaultValue = "1") Integer pageNum,
                             @RequestParam (defaultValue = "10")Integer pageSize) {
        PageInfo<Album> pageInfo =  albumService.selectPage(album,pageNum,pageSize);
        return Result.success(pageInfo);
    }

    @PostMapping("/addPic")
    public Result addPic(@RequestBody Album album) {
        albumService.addPic(album);
        return Result.success();}

    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Integer id) {
        albumService.deleteById(id);
        return Result.success();
    }

   @DeleteMapping("/deleteBatch")
    public Result deleteBatch(@RequestBody List<Integer> ids) {
        albumService.deleteBatch(ids);
       return Result.success();
   }

    @PutMapping("/update")
    public Result update(@RequestBody Album album) {
        albumService.update(album);
        return Result.success();
    }

    @GetMapping("/selectById/{time}")
    public Result selectById(@PathVariable String time) {
        Album album = albumService.selectById(time);
        return Result.success(album);
    }
    @GetMapping("/selectAll")
    public Result selectAll(Album album) {
        List<Album> list = albumService.selectAll(album);
        return Result.success(list);
    }

}//
